package com.xf.spring.factoryBean;

import org.springframework.beans.factory.FactoryBean;

/**
 * Created by xiefei on 2015/12/28.
 */
public class CarFactoryBean implements FactoryBean {

    private String brand;
    private double price;

    public void setBrand(String brand) {
        this.brand = brand;
    }

    @Override
    public String toString() {
        return "CarFactoryBean{" +
                "brand='" + brand + '\'' +
                ", price=" + price +
                '}';
    }

    public void setPrice(double price) {
        this.price = price;
    }

    //返回bean的对象
    @Override
    public Object getObject() throws Exception {
        return new Car(brand, price);
    }

    //返回bean的类型
    @Override
    public Class<?> getObjectType() {
        return Car.class;
    }

    //返回bean是否为单例模式
    @Override
    public boolean isSingleton() {
        return true;
    }
}
